package com.neusoft.controller;

import com.neusoft.response.ApiResponse;
import com.neusoft.service.IProfileService;
import com.neusoft.vo.ProfileVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api")
public class ProfileController {
    @Autowired
    IProfileService iProfileService;

    @GetMapping("/profiles/{username}")
    public ApiResponse<ProfileVo> getProfile(@PathVariable("username") String username) {
        return ApiResponse.success(iProfileService.getProflie(username));
    }

    @PostMapping("/profiles/{username}/follow")
    public ApiResponse<ProfileVo> follow(@PathVariable("username") String username) {
        return ApiResponse.success(iProfileService.follow(username));
    }
    @DeleteMapping("/profiles/{username}/follow")
    public ApiResponse<ProfileVo> unfollow(@PathVariable("username") String username) {
        return ApiResponse.success(iProfileService.unFollow(username));
    }
}
